<?php 
	// phpinfo();die;													// get phpinfo														
	
	require_once('Zend/Loader/Autoloader.php');
	$loader = Zend_Loader_Autoloader::getInstance();
	// $loader -> registerNamespace(array('Foo_', 'Bar_'));				// add namespace
	// $loader -> setFallbackAutoloader(true);							// handle all classes and ignore its namespace
	
	// register web site config information as global var $config
	$config = new Zend_Config_Ini('../settings.ini', 'development');
	Zend_Registry::set('config', $config);
	
	// create the application logger
	$logger = new Zend_Log(new Zend_Log_Writer_Stream($config -> logging -> file));
	Zend_Registry::set('logger', $logger);
	
	// $logger -> log('Test', Zend_Log::DEBUG);						   // test logger
	// $logger -> debug('Test2');									   // test logger
	
	// register db information as global var $db
	$params = array('host'     => $config -> database -> hostname,
					'username' => $config -> database -> username,
	                'password' => $config -> database -> password,
					'dbname'   => $config -> database -> database);
	$db = Zend_Db::factory($config -> database -> type, $params);
	Zend_Registry::set('db', $db);
	// $db -> query('select 1');die;									// test db connection
	
	// initialize main controller
	$controller = Zend_Controller_Front::getInstance();
	$controller -> setControllerDirectory($config -> paths -> base . '/include/Controllers');
	$controller -> throwExceptions(true);
	
	// setup the view renderer
	require_once 'Templater.php';
	$vr = new Zend_Controller_Action_Helper_ViewRenderer();
	$vr -> setView(new Templater());
	$vr -> setViewSuffix('tpl');
	Zend_Controller_Action_HelperBroker::addHelper($vr);
	
	// begin dispatch
	$controller -> dispatch();
?>